cmake_minimum_required(VERSION 3.10)
project(lightdm VERSION 1.32.0)


option(COMPILE_TESTS "compile tests?" ON)
option(HAVE_INTROSPECTION "enable introspection?" ON)
option(ENABLE_VAPIGEN "enable vapigen?" ON)
option(COMPILE_LIBLIGHTDM_QT5 "compile liblightdm-qt5" OFF)
option(HAVE_LIBAUDIT "libaudit support" ON)
option(DEFAULT_USER_SESSION "DEFAULT USERSESSION" ON)
option(DEFAULT_GREETER_SESSION "DEFAULT GREETER SESSION" ON)
option(GREETER_USER "User to run greeter as" ON)

#ACLOCAL_AMFLAGS = -I m4
#SUBDIRS = common liblightdm-gobject liblightdm-qt
#if COMPILE_TESTS
#SUBDIRS += tests
#endif
#SUBDIRS += data po src doc help

set(WARN_CFLAGS "-Wall \
             -Wstrict-prototypes \
             -Wnested-externs \
             -Werror=missing-prototypes \
             -Werror=implicit-function-declaration \
             -Werror=pointer-arith \
             -Werror=init-self \
             -Werror=format-security \
             -Werror=format=2 \
             -Werror=missing-include-dirs"
    )

set(WARN_CXXFLAGS "-Wall")

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h "")
include_directories(${CMAKE_CURRENT_BINARY_DIR})

include(GNUInstallDirs)

find_package(PkgConfig)
set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig")
pkg_check_modules(GLIB IMPORTED_TARGET glib-2.0) #>=2.44
pkg_check_modules(GIO IMPORTED_TARGET gio-2.0) #>=2.26
pkg_check_modules(GIO_UNIX IMPORTED_TARGET gio-unix-2.0)
pkg_check_modules(GOBJECT IMPORTED_TARGET gobject-2.0)
pkg_check_modules(XDMCP IMPORTED_TARGET xdmcp)
pkg_check_modules(XCB IMPORTED_TARGET xcb)
pkg_check_modules(XKLAVIER IMPORTED_TARGET libxklavier)
pkg_check_modules(X11 IMPORTED_TARGET x11)
pkg_check_modules(GCRYPT IMPORTED_TARGET libgcrypt)
pkg_check_modules(PAM IMPORTED_TARGET pam)

add_library(macros-interface
        INTERFACE
)
target_compile_definitions(macros-interface
        INTERFACE
        CONFIG_DIR="${CMAKE_INSTALL_PREFIX}/etc/lightdm"
        SESSIONS_DIR="${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/sessions:${CMAKE_INSTALL_DATADIR}/xsessions:${CMAKE_INSTALL_DATADIR}/wayland-sessions"
        REMOTE_SESSIONS_DIR="${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/remote-sessions"
        GETTEXT_PACKAGE="${PROJECT_NAME}"
        VERSION="${PROJECT_VERSION}"
        GREETER_USER="lightdm"
        DEFAULT_GREETER_SESSION="default"
        DEFAULT_USER_SESSION="default"
)

add_subdirectory(common)
add_subdirectory(liblightdm-gobject)
# add_subdirectory(liblightdm-qt)
#if (COMPILE_TESTS)
#    add_subdirectory(tests)
#endif()
#add_subdirectory(data)
#add_subdirectory(po)
add_subdirectory(src)
#add_subdirectory(doc)
#add_subdirectory(help)


#
#DISTCHECK_CONFIGURE_FLAGS = --enable-introspection --enable-gtk-doc
#
#EXTRA_DIST = \
#	autogen.sh \
#	lightdm.doap \
#	COPYING.GPL3 \
#	COPYING.LGPL2 \
#	COPYING.LGPL3 \
#	NEWS
#
#DISTCLEANFILES = po/.intltool-merge-cache.lock
#

#GTK_DOC_CHECK
#YELP_HELP_INIT
